package com.fly.consultant.controller;

import com.fly.consultant.service.ConsultantService;
import dev.langchain4j.model.openai.OpenAiChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
public class ChatController {

    // 注入OpenAiChatModel
    @Autowired
    private OpenAiChatModel openAiChatModel;

    @Autowired
    private ConsultantService consultantService;


    // 流式调用
    @GetMapping(value = "/chat",produces = "text/html;charset=UTF-8")
    public Flux<String> chat(String memoryId,String message) {
        // 调用chat方法
        return consultantService.chat(memoryId,message);
    }
    // 阻塞式调用
//    @GetMapping("/chat")
//    public String chat(String message) {
//        // 调用chat方法
//        return consultantService.chat(message);
//    }

    // 聊天接口
//    @GetMapping("/chat")
//    public String chat(String message) {
//        // 调用chat方法
//        return openAiChatModel.chat(message);
//    }

}
